package com.aqie.libfactory.model.card;


import com.aqie.libfactory.model.IMessage;
import com.aqie.libfactory.model.db.Message;
import com.aqie.libfactory.model.db.User;

import java.util.Date;

public class MessageCard extends Message{

    public MessageCard() {
    }
    public MessageCard(IMessage message) {
        this.msgId = message.getMsgId();
        this.msg = message.getMsg();
        this.senderId = message.getSenderId();
        this.receiverId = message.getReceiverId();
    }

    private String msgId;//主键

    private String msg;// 内容

    private String attach;// 附属信息

    private int type;// 消息类型

    private Date createAt;// 创建时间

    private int status;// 当前消息的状态

    private String groupId;


    private String senderId;

    private String receiverId;


    @Override
    public String getMsgId() {
        return msgId;
    }

    @Override
    public void setMsgId(String msgId) {
        this.msgId = msgId;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    @Override
    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public String getAttach() {
        return attach;
    }

    @Override
    public void setAttach(String attach) {
        this.attach = attach;
    }

    @Override
    public int getType() {
        return type;
    }

    @Override
    public void setType(int type) {
        this.type = type;
    }

    @Override
    public Date getCreateAt() {
        return createAt;
    }

    @Override
    public void setCreateAt(Date createAt) {
        this.createAt = createAt;
    }

    @Override
    public int getStatus() {
        return status;
    }

    @Override
    public void setStatus(int status) {
        this.status = status;
    }

    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }


    @Override
    public String getSenderId() {
        return senderId;
    }

    @Override
    public void setSenderId(String senderId) {
        this.senderId = senderId;
    }

    @Override
    public String getReceiverId() {
        return receiverId;
    }

    @Override
    public void setReceiverId(String receiverId) {
        this.receiverId = receiverId;
    }

    /**
     * 要构建一个消息，必须准备好3个外键对应的Model
     *
     * @param sender   发送者ID
     * @param receiver 接收者ID
     * @return 一个消息
     */
    public Message build(User sender, User receiver) {
        Message message = new Message();
        message.setMsg(msg);
        message.setMsgId(msgId);
        message.setAttach(attach);
        message.setType(type);
        message.setCreateAt(createAt);
        message.setSender(sender);
        message.setReceiver(receiver);
        message.setStatus(status);
        message.setCreateAt(new Date());
        return message;
    }
}
